package com.biz.primus.app.rest.controller.order;

import com.biz.primus.app.rest.controller.base.RestBaseController;
import com.biz.primus.app.rest.feign.order.OrderEvaluationFeignClient;
import com.biz.primus.base.global.GlobalParams;
import com.biz.primus.model.evaluation.vo.DeliveryEvaluationVO;
import com.biz.primus.model.evaluation.vo.OrderEvaluationVO;
import com.biz.primus.model.evaluation.vo.ProductEvaluationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 订单评价
 *
 * @author Tiger Feng
 * @date 2017年11月28日
 */
@RestController
@RequestMapping("order")
@Api("前台订单评价相关接口文档")
public class OrderEvaluationController extends RestBaseController {
    @Autowired
    private OrderEvaluationFeignClient evaluationService;

    @ApiOperation(value = "评价快递员", notes = "订单确认收货后，对订单的快递员评价(订单状态：已付款、部分付款、已收货、未评价)")
    @PostMapping("courier")
    public OrderEvaluationVO evaluateCourier(
            GlobalParams gp,
            @RequestBody DeliveryEvaluationVO vo) {
        super.buildRequest(gp, vo);
        return evaluationService.evaluateCourier(vo);
    }

    @ApiOperation(value = "评价商品", notes = "订单确认收货后，对订单下的商品进行评价(订单状态：已付款、部分付款、已收货、未评价)")
    @PostMapping("product")
    public OrderEvaluationVO evaluateProduct(
            GlobalParams gp,
            @RequestBody ProductEvaluationVO vo) {
        super.buildRequest(gp, vo);
        return evaluationService.evaluateProduct(vo);
    }

    @ApiOperation("查询订单信息,根据订单编号")
    @GetMapping("getOrderEvalutionByOrderCode")
    public OrderEvaluationVO getOrderEvalutionByOrderCode(
            GlobalParams gp,
            @ApiParam(value = "订单编号", required = true) @RequestParam("orderCode") String orderCode) {
        return evaluationService.getOrderEvalutionByOrderCode(orderCode);
    }
}
